Mortgage Demo Example

[1]:
from cuXfilter import charts
import cuXfilter
from bokeh import palettes
from cuXfilter.layouts import layout_1
import warnings
warnings.filterwarnings('ignore')
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-a0c1265f56ae> in <module>
      2 import cuXfilter
      3 from bokeh import palettes
----> 4 from cuXfilter.layouts import layout_1
      5 import warnings
      6 warnings.filterwarnings('ignore')

ImportError: cannot import name 'layout_1' from 'cuXfilter.layouts' (/home/ajay/cuXfilter-version-control/cuxfilter/python/cuXfilter/layouts/__init__.py)

Load cuXfilter dataframe

[2]:
cux_df = cuXfilter.DataFrame.from_arrow('/home/ajay/data/146M_predictions_v2.arrow')

Define Charts

[3]:
chart0 = charts.bokeh.choropleth(x='zip', y='delinquency_12_prediction', aggregate_fn='mean',
                                  geo_color_palette=palettes.Inferno256,
                                  geoJSONSource = 'https://raw.githubusercontent.com/rapidsai/cuxfilter/master/javascript/demos/GTC%20demo/src/data/zip3-ms-rhs-lessprops.json',
                                  data_points=1000, width=1100, x_range=(-126, -66), y_range=(23, 50))
chart2 = charts.bokeh.bar('delinquency_12_prediction',data_points=50, width=400, height=400)
chart3 = charts.panel_widgets.range_slider('borrower_credit_score',data_points=50,width=400, height=400)

Add mappings for chart1

[4]:
mapper1 = {}

for val in cux_df.data.dti.unique().to_pandas().tolist():
    mapper1[int(val)] = 'l_'+str(val)

chart1 = charts.panel_widgets.multi_select('dti', width=400, height=400, label_map=mapper1)
#also available: panel_widgets.dropdown

Create dashboard

[5]:
d = cux_df.dashboard([chart0, chart1], layout=layout_1, title="Ajay's Dashboard")
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-5-665760ae4a18> in <module>
----> 1 d = cux_df.dashboard([chart0, chart1], layout=layout_1, title="Ajay's Dashboard")

NameError: name 'layout_1' is not defined
[6]:
#add more charts
d.add_charts([chart2, chart3])
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-6-676510c54145> in <module>
      1 #add more charts
----> 2 d.add_charts([chart2, chart3])

NameError: name 'd' is not defined
[7]:
# d.show('url you want the dashboard to run') remote dashboard:
# d.app('10.110.47.43:8888') within the notebook: If you are using jupyter remotely, use this line instead of second, and replace url with current notebook url
#d.app() for local interactive behavior

#d.preview() for just a view of the dashboard, interaciton not available. Recommended way to generate when uploading to git remote site
await d.preview()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-7-d9cb0435fb09> in async-def-wrapper()

NameError: name 'd' is not defined

Export the queried data into a dataframe

[8]:
queried_df = d.export()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-8-5f1dbc176995> in <module>
----> 1 queried_df = d.export()

NameError: name 'd' is not defined